<?php

class ExtensionClass {

    public static function dumpAllArticleCategoryToArray($parentId = 0, $maxLevel = 0, $status='') {
        $tree   = array();
        $categories = Lvc::select('a_category', 'id,a_category_name as name, url_key, sorder,parent', 'parent='.$parentId.' AND status = '.Lvc::STATUS_ENABLED, 'sorder, id');
        foreach($categories as $category)
        {
            self::dumpArticleCategoryChildren($category, 1, $maxLevel);
            array_push($tree, $category);
        }
        return $tree;
    }
    public static function AcatArray(){
        $new_data = array();
        $datas =  Lvc::select('a_category', 'id,a_category_name as name', 'parent=0 AND status = '.Lvc::STATUS_ENABLED, 'sorder, id',null,'id');
        foreach($datas as $data){
            $new_data[$data['id']] = $data['name'];
        }
        unset($datas);
        return $new_data;
    }

    public static function getCatName($cat_id = 0){
        $data = Lvc::selectOne(ACategory::model()->tableName(),'a_category_name', 'id='.$cat_id);
        return is_array($data) ? $data['a_category_name'] : '-- Thư mục chính --';
    }
    // lấy chuyên mục sản phẩm
    public static function produc_cat_arr($new_data=array()){
        $datas = Lvc::select(ProductCategory::model()->tableName(), 'id,product_category_name', 'status='.Lvc::STATUS_ENABLED, 'sorder desc');
        if(!$datas) return array();
        foreach ($datas as $data) $new_data[$data['id']] = $data['product_category_name'];
        return $new_data;
    }
    // danh sách hãng sản xuất
    public static function brand_arr(){
        $datas = Lvc::select(Maker::model()->tableName(), 'id,maker_name', 'status='.Lvc::STATUS_ENABLED, 'sorder desc');
        if(!$datas) return array();
        foreach ($datas as $data) $new_data[$data['id']] = $data['maker_name'];
        return $new_data;
    }
}

?>
